package flc.ast.adapter;

import android.graphics.Color;
import android.view.View;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.google.gson.Gson;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import flc.ast.R;
import me.zhouzhuo.zzratingbar.ZzRatingBar;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;
import stark.common.bean.StkResBean;

public class HotAdapter extends StkProviderMultiAdapter<StkResBean> {

    public HotAdapter() {
        addItemProvider(new StkSingleSpanProvider(126));
        addItemProvider(new HotProvider());
    }

    private class HotProvider extends BaseItemProvider<StkResBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_hot;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, StkResBean bean) {
            if (baseViewHolder.getBindingAdapterPosition() == 0) {
                baseViewHolder.setTextColor(R.id.tvHotItemNum, Color.parseColor("#FF2B49"));
                baseViewHolder.getView(R.id.line).setVisibility(View.INVISIBLE);
            } else if (baseViewHolder.getBindingAdapterPosition() == 1) {
                baseViewHolder.setTextColor(R.id.tvHotItemNum, Color.parseColor("#FF965A"));
                baseViewHolder.getView(R.id.line).setVisibility(View.VISIBLE);
            } else if (baseViewHolder.getBindingAdapterPosition() == 2) {
                baseViewHolder.setTextColor(R.id.tvHotItemNum, Color.parseColor("#FDA00F"));
                baseViewHolder.getView(R.id.line).setVisibility(View.VISIBLE);
            } else {
                baseViewHolder.setTextColor(R.id.tvHotItemNum, Color.parseColor("#727E96"));
                baseViewHolder.getView(R.id.line).setVisibility(View.VISIBLE);
            }
            baseViewHolder.setText(R.id.tvHotItemNum, (baseViewHolder.getBindingAdapterPosition() + 1) + "");
            baseViewHolder.setText(R.id.tvHotItemName, "." + bean.getName());
        }
    }

}
